package com.innovation.chengzhangriji.ui.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CuteViewPager extends ViewPager {

    private boolean enabledScroll = false;

    public CuteViewPager(Context context) {
        super(context);
    }

    public CuteViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(enabledScroll) {
            return super.onInterceptTouchEvent(ev);
        }
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if(enabledScroll) {
            return super.onTouchEvent(ev);
        }
        return false;
    }

    public boolean canScroll() {
        return enabledScroll;
    }

    public void enabledScroll(boolean enabledScroll) {
        this.enabledScroll = enabledScroll;
    }
}
